package de.uni.webprog.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.SimpleCheckBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

public class Login extends Composite {
	private TextBox textBox;
	private PasswordTextBox passwordTextBox;

	public Login() {
		
		VerticalPanel verticalPanel = new VerticalPanel();
		initWidget(verticalPanel);
		
		Label lblNewLabel = new Label("Hier beim Account anmelden");
		verticalPanel.add(lblNewLabel);
		
		FlexTable flexTable = new FlexTable();
		verticalPanel.add(flexTable);
		flexTable.setSize("237px", "72px");
		
		Label lblUsername = new Label("Username");
		flexTable.setWidget(0, 0, lblUsername);
		lblUsername.setSize("81px", "17px");
		flexTable.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
		
		textBox = new TextBox();
		flexTable.setWidget(0, 1, textBox);
		
		Label lblPasswort = new Label("Passwort");
		flexTable.setWidget(1, 0, lblPasswort);
		
		passwordTextBox = new PasswordTextBox();
		flexTable.setWidget(1, 1, passwordTextBox);
		
		SimpleCheckBox simpleCheckBox = new SimpleCheckBox();
		flexTable.setWidget(2, 0, simpleCheckBox);
		flexTable.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
		
		Label lblAufDemPc = new Label("Auf dem PC merken");
		flexTable.setWidget(2, 1, lblAufDemPc);
		
		Button btnNewButton = new Button("New button");
		btnNewButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				if (textBox.getText().length() == 0){
					Window.alert("Username or password is empty");
				}
			}
		});
		btnNewButton.setStyleName("gwt-Label-Login");
		btnNewButton.setText("Login");
		flexTable.setWidget(3, 1, btnNewButton);
	}

}
